<template>
	<view class="content">
		<u-navbar :is-back="false" title=" ">
			<view class="slot-wrap paddinglR-20" @click="region.show = true;">
				<u-icon name="map-fill" color="#000" size="30rpx"></u-icon><text class="padding-l-5">{{ region.city ?
					region.city : '--' }}</text>
			</view>
		</u-navbar>
		<view class="fs28 margin-bottom-10 margin-t-10">
			<text>测试技师</text>
			<view style="float: right;">
				<u-switch active-color="#f37b1d" inactive-color="#eee" size="30" v-model="checked"></u-switch>
			</view>
		</view>

		<view class="padding flex text-center text-grey bg-white shadow-warp">
			<view class="flex flex-sub flex-direction solid-right animation-slide-top"
				:style="[{ animationDelay: '0.2s' }]">
				<view class="text-xl text-orange">20单</view>
				<view class="margin-top-sm">今日接单数</view>
			</view>

			<view class="flex flex-sub flex-direction animation-slide-top" :style="[{ animationDelay: '0.2s' }]">
				<view class="text-xl text-orange">32单</view>
				<view class="margin-top-sm">今日收入</view>
			</view>
		</view>
		<view class="padding flex text-center text-grey bg-white shadow-warp">
			<view class="flex flex-sub flex-direction solid-right animation-slide-top"
				:style="[{ animationDelay: '0.2s' }]">
				<view class="text-xl text-orange">32单</view>
				<view class="margin-top-sm">本月接单数</view>
			</view>
			<view class="flex flex-sub flex-direction animation-slide-top" :style="[{ animationDelay: '0.2s' }]">
				<view class="text-xl text-orange">32单</view>
				<view class="margin-top-sm">本月收入</view>
			</view>
		</view>
		<view class="home-nav" style="height: 100%;">
			<u-tabs :list="list" active-color="#f37b1d" inactive-color="#606266" font-size="32" :is-scroll="false"
				:current="current" @change="change"></u-tabs>
			<view class="home-list">
				<view class="home-item" v-for="(item,index) in orderList" :key="index">
					<!-- 上 -->
					<view class="project">
						<view class="project-name">
							<image src="../../static/service.png" mode=""></image>
							<h4>
								{{item.name}}
							</h4>
						</view>
						<view :class="item.status == 0?'red':item.status == 1?'blue':item.status == 2?'orange':'green'">
							{{item.status==0?'待接单':item.status==1?'待服务':item.status==2?'服务中':'已完成'}}
						</view>
					</view>
					<!-- 中 -->
					<view class="order">
						<view class="order-time">
							<span>预定时间：{{item.bookingTime}}</span>
							<span>下单时间：{{item.orderTime}}</span>
							<span>订单编号：{{item.orderNum}}</span>
						</view>
						<view class="order-position" style="color: #333;" @click="viewPosition">
							查看位置
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
					<!-- 下 -->
					<view class="order-btn">
						<view class="order-connection btn-box">
							拔打电话
						</view>
						<view class="order-taking">
							<view class="btn-box">
								接单
							</view>
							<view class="btn-box left">
								取消订单
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<city-select :data="region" @func="confirmCity" @func2="reginHidden"></city-select>
	</view>
</template>

<script>
	import citySelect from "@/component/city-select.vue";
	export default {
		components: {
			citySelect
		},
		data() {
			return {
				// 市区
				region: {
					show: false,
					updateUserInfo: true,
					city: null, //城市名字
					cityId: null, //城市Id
				},
				list: [{
					name: '待接单'
				}, {
					name: '待服务'
				}, {
					name: '服务中',
				}, {
					name: '已完成',
				}],
				orderList: [{
						name: '中式按摩',
						bookingTime: '2023-06-05 12:12:12',
						orderTime: '2023-06-05 12:12:12',
						orderNum: 1213434546546356,
						status: 0 //待接单
					},
				],
				current: 0,
				active: 2,
				checked: false, // 初始化为未选中状态
				title: 'Hello'
			}
		},
		onLoad() {

		},
		methods: {
			onInput(checked) {
				this.checked = !this.checked
			},
			//省市选择更新
			confirmCity(data) {
				this.region.city = data.name;
				this.region.cityId = data.code;
				this.region.show = false;
			},
			//隐藏地址选择
			reginHidden() {
				this.region.show = false;
			},
			change(index) {
				this.current = index;
				switch (index) {
					case 0:
						this.orderList = [{
							name: '中式按摩',
							bookingTime: '2023-06-05 12:12:12',
							orderTime: '2023-06-05 12:12:12',
							orderNum: 1213434546546356,
							status: 0 //待接单
						}, ]
						break;
					case 1:
						this.orderList = [{
							name: '中式按摩',
							bookingTime: '2023-06-05 12:12:12',
							orderTime: '2023-06-05 12:12:12',
							orderNum: 1213434546546356,
							status: 1 //待接单
						}, ]
						break;
					case 2:
						this.orderList = [{
							name: '中式按摩',
							bookingTime: '2023-06-05 12:12:12',
							orderTime: '2023-06-05 12:12:12',
							orderNum: 1213434546546356,
							status: 2 //待接单
						}, ]
						break;
					case 3:
						this.orderList = [{
							name: '中式按摩',
							bookingTime: '2023-06-05 12:12:12',
							orderTime: '2023-06-05 12:12:12',
							orderNum: 1213434546546356,
							status: 3 //待接单
						}, ]
						break;

					default:
						break;
				}
			},
			// 查看位置
			viewPosition() {
				uni.navigateTo({
					url: '/pages/position/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-tabs__wrapper__nav__item {
		width: 25%;
		background: pink;
	}

	.content {
		width: 100%;
		height: 100vh;
		padding: 0 20rpx;
		background: #fff;
		overflow: hidden;
	}

	.dqwz {
		font-size: 28rpx
	}

	.fs28 {
		font-size: 28rpx
	}

	.fs34 {
		font-size: 34rpx;
		font-weight: 500;
	}

	.fs24 {
		font-size: 24rpx
	}

	.margin-bottom-10 {
		margin-bottom: 20rpx;

	}

	::v-deep .u-tabs {
		margin: 20rpx 0;
	}

	.home-list {
		height: calc(100% - 700rpx);
		overflow-y: auto;

		.home-item {
			width: 100%;
			background: linear-gradient(to left, #fff, #FBEAD8);
			border-radius: 20rpx;
			padding: 20rpx;
			margin-bottom: 60rpx;
			box-shadow: -2px 0px 10px 2px #ede6e1;
			font-size: 30rpx;
			color: #999;

			.project {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-bottom: 10px;
				border-bottom: 1px solid #d3d3d3;

				image {
					width: 60rpx;
					height: 60rpx;
					margin-right: 20rpx;
				}

				h4 {
					color: #333;
				}

				.project-name {
					display: flex;
					align-items: center;
					font-size: 36rpx
				}

				.red {
					color: #ff7070;
				}

				.blue {
					color: #417ADC;
				}

				.orange {
					color: #FFAD0E;
				}

				.green {
					color: #41DC83;
				}
			}

			.order {
				display: flex;
				justify-content: space-between;
				line-height: 48rpx;
				padding: 20rpx 0;

				.order-time {
					display: flex;
					flex-direction: column;
				}
			}

			.order-btn {
				display: flex;
				justify-content: space-between;

				.order-taking {
					display: flex;
				}

				.btn-box {
					padding: 10rpx 20rpx;
					border: 1px solid #999;
					border-radius: 10rpx;
					background-color: #fff;
					color: #333;
				}

				.left {
					margin-left: 20rpx;
				}
			}
		}
	}
</style>